//
//  SYChuangHeaderView.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/4/22.
//  Copyright © 2019年 SanYi. All rights reserved.
//

#import "SYChuangHeaderView.h"
#import "SYFuntionHeaderView.h"
#import "SYTopLabView.h"

@interface SYChuangHeaderView ()
@property (strong, nonatomic) SYFuntionHeaderView *headerViewKS;//开始
@property (strong, nonatomic) SYFuntionHeaderView *headerViewJS;//结束
@property (strong, nonatomic) SYFuntionHeaderView *headerViewCY;//成员数量
@property (strong, nonatomic) SYFuntionHeaderView *headerViewXZ;//小组简介
@property (strong, nonatomic) SYFuntionHeaderView *headerViewZT;//当前状态
@property (strong, nonatomic) UILabel *xiaozuLab;
@property (strong, nonatomic) SYTopLabView *topLabView;
@property (assign, nonatomic) SYChuangHeaderViewType type;
@end


@implementation SYChuangHeaderView

- (instancetype)initWithType:(SYChuangHeaderViewType)type {
    self = [super init];
    if (self) {
        _type = type;
        [self initSubView];
        
    }
    return self;
}

- (void)initSubView {
    CGFloat height = 40;
    CGFloat width = 330;
    [self addSubview:self.headerViewZT];
    //名称
    [self.headerViewZT mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(10);
        make.left.equalTo(self.mas_left).offset(70);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(height);
    }];
    [self addSubview:self.headerViewCY];
    //成员
    [self.headerViewCY mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.headerViewZT.mas_centerY);
        make.left.equalTo(self.mas_centerX).offset(70);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(height);
    }];
    //开始日期
    [self addSubview:self.headerViewKS];
    [self.headerViewKS mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.headerViewZT.mas_centerX);
        make.trailing.equalTo(self.headerViewZT.mas_trailing);
        make.top.equalTo(self.headerViewZT.mas_bottom).offset(10);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(height);
    }];
    //结束日期
    [self addSubview:self.headerViewJS];
    [self.headerViewJS mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(self.headerViewCY.mas_trailing);
        make.centerY.equalTo(self.headerViewKS.mas_centerY);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(height);
    }];
    [self addSubview:self.headerViewXZ];
    //小组简介
    [self.headerViewXZ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.headerViewKS.mas_centerX);
        make.trailing.equalTo(self.headerViewKS.mas_trailing);
        make.top.equalTo(self.headerViewKS.mas_bottom).offset(10);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(height);
    }];
    //小组成员
    [self addSubview:self.xiaozuLab];
    [self.xiaozuLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.top.equalTo(self.headerViewXZ.mas_bottom).offset(18);
    }];
    //标题
    [self addSubview:self.topLabView];
    [self.topLabView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.top.equalTo(self.xiaozuLab.mas_bottom).offset(15);
        make.left.equalTo(self.mas_left).offset(0);
        make.right.equalTo(self.mas_right).offset(0);
        make.height.mas_equalTo(40);
    }];
    
}

//开始日期
- (SYFuntionHeaderView *)headerViewKS {
    if (!_headerViewKS) {
        _headerViewKS = [[SYFuntionHeaderView alloc] init];
        _headerViewKS.titleLab.text = @"开始日期: ";
        _headerViewKS.contLab.hidden = YES;
        _headerViewKS.xhxView.hidden = YES;
        _headerViewKS.selectView.hidden = NO;
    }
    return _headerViewKS;
}
//结束日期
- (SYFuntionHeaderView *)headerViewJS {
    if (!_headerViewJS) {
        _headerViewJS = [[SYFuntionHeaderView alloc] init];
        _headerViewJS.titleLab.text = @"结束日期: ";
        _headerViewJS.contLab.hidden = YES;
        _headerViewJS.xhxView.hidden = YES;
        _headerViewJS.selectView.hidden = NO;
    }
    return _headerViewJS;
}
//成员数量 headerViewXZ
- (SYFuntionHeaderView *)headerViewCY {
    if (!_headerViewCY) {
        _headerViewCY = [[SYFuntionHeaderView alloc] init];
        _headerViewCY.titleLab.text = @"成员数量: ";
        _headerViewCY.contLab.hidden = YES;
        _headerViewCY.textField.placeholder = @"请输入成员数据";
        _headerViewCY.textField.textColor = [UIColor colorWithHexString:@"#FF4800"];
        _headerViewCY.textField.keyboardType = UIKeyboardTypeNumberPad;
    }
    return _headerViewCY;
}
//小组简介
- (SYFuntionHeaderView *)headerViewXZ {
    if (!_headerViewXZ) {
        _headerViewXZ = [[SYFuntionHeaderView alloc] init];
        _headerViewXZ.titleLab.text = @"小组简介: ";
        _headerViewXZ.contLab.hidden = YES;
        _headerViewXZ.textField.placeholder = @"请输入小组简介";
    }
    return _headerViewXZ;
}

- (SYFuntionHeaderView *)headerViewZT {
    if (!_headerViewZT) {
        _headerViewZT = [[SYFuntionHeaderView alloc] init];
        _headerViewZT.titleLab.text = @"名称: ";
//        _headerViewZT.contLab.text = @"进行中";
//        _headerViewZT.contLab.textColor = [UIColor colorWithHexString:@"#FF4800"];
        _headerViewZT.contLab.hidden = YES;
        _headerViewZT.textField.placeholder = @"请输入小组名称";
    }
    return _headerViewZT;
}
- (UILabel *)xiaozuLab {
    if (!_xiaozuLab) {
        _xiaozuLab = [UILabel titleColour:TITLECOLOR
                               titleFount:14
                                 pingfang:@"PingFang-SC-Medium"
                                alignment:NSTextAlignmentCenter
                                titleLine:1];
        _xiaozuLab.text = @"小组成员";
        
    }
    return _xiaozuLab;
}

- (SYTopLabView *)topLabView {
    if (!_topLabView) {
        NSArray *xiaoArr = nil;
        CGFloat bili;
        if (_type == SYChuangHeaderViewTypeShiXun) {
            xiaoArr = @[@"工号",@"姓名",@"性别",@"手机号",@"添加日期",@"移除"];
            bili = 0.167;
        } else {
            xiaoArr = @[@"工号",@"姓名",@"性别",@"手机号",@"角色",@"添加日期",@"移除"];
            bili = 0.143;
        }
        
        _topLabView = [[SYTopLabView alloc] initWithDataNameArr:xiaoArr width:bili];
    }
    return _topLabView;
}

@end























